<?php

namespace App\Api\Requests;

use Dingo\Api\Exception\ResourceException;
use Dingo\Api\Http\FormRequest as BaseFormRequest;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Http\Request;

class FormRequest extends BaseFormRequest
{
    public function authorize()
    {
        return true;
    }

    protected function failedValidation(Validator $validator)
    {
        if ($this->container['request'] instanceof Request) {
            throw new ResourceException($validator->errors()->first(),$validator->errors());
        }

        parent::failedValidation($validator);
    }
}